<template>
	<view class="container">
		<view class="header">
			<view class="headerBg"></view>
		</view>
		<view class="listTop" @tap="toLink(hot.url)">
			<view class="label">
				<image src="https://inclusivecommunity.oss-cn-chengdu.aliyuncs.com/attach/2020-09/54c6a202009211345116485.png" mode=""></image>
				<text>热销精品</text>
			</view>
			<view class="title">
				<image :src="hot.img" mode=""></image>
				<text>{{hot.name}}</text>
			</view>
			<view class="count">
				<text class="a">{{hot.money_max}}</text>
				<text class="b">最高额度（元）</text>
			</view>
			<view class="desc">
				<view class="a">
					<text class="a-a">借款周期 : </text>
					<text class="a-b">{{hot.cycle}}</text>
				</view>
				<view class="a">
					<text class="a-a">日利率 : </text>
					<text class="a-b">{{hot.day_rate}}</text>
				</view>
			</view>
		</view>
		<view class="List">
			<view class="title">精选·手机贷</view>
			<view class="item" v-for="(item,index) in list" :key="index" @tap="toLink(item.url)">
				<view class="title">
					<view class="goOut">
						<text class="yticon icon-you"></text>
					</view>
					<image :src="item.img" mode=""></image>
					<text>{{item.name}}</text>
				</view>
				<view class="box">
					<view class="count">
						<text class="a">{{item.money_max}}</text>
						<text class="b">最高额度（元）</text>
					</view>
					<view class="desc">
						<view class="a">
							<text class="a-a">借款周期 : </text>
							<text class="a-b">{{item.cycle}}</text>
						</view>
						<view class="a">
							<text class="a-a">日利率 : </text>
							<text class="a-b">{{item.day_rate}}</text>
						</view>
					</view>
				</view>
			</view>
			<uni-load-more class="loadMore" iconType="circle" :status="loadStatus" :contentText="contentText"></uni-load-more>
		</view>
	</view>
</template>

<script>
	import {jinService} from "@/api/public.js"
	import utils from "@/common/utils.js"
	export default {
		data() {
			return {
				page: 1,
				limit: 5,
				loadStatus: "loading",
				contentText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多了"
				},
				hot: {},
				list: []
			}
		},
		onLoad() {
			this.getJinService()
		},
		onReachBottom() {
			if (this.loadStatus == "more")
				(this.loadStatus = "loading"), this.jinService();
		},
		methods:{
			getJinService() {
				jinService().then(res => {
					this.loadStatus = "more";
					this.hot = res.data.hot
					this.hot.money_max = utils.format(this.hot.money_max)
					let list = res.data.list.map((val,key) => {
						val.money_max = utils.format(val.money_max)
						return val
					})
					this.list.push.apply(this.list, list);
					if (list.length < this.limit) this.loadStatus = "noMore"; //判断所有数据是否加载完成；
					this.page = this.page + 1;
					if (this.list.length == 0) {
						this.nodata = true
						this.contentText.contentnomore = ''
					} else {
						this.nodata = false
					}
				})
			},
			toLink(url){
				uni.navigateTo({
					url: "./webView?link=" + encodeURIComponent(url)
				})
			}
		}
	}
</script>
<style>
	page {
		background-color: #fafafa;
	}
</style>
<style lang="scss" scoped>
	.container {
		.header {
			height: 160rpx;
			overflow: hidden;
			position: relative;
			//#ifndef H5
			z-index: -1;
			//#endif

			.headerBg {
				position: absolute;
				left: -75rpx;
				width: 900rpx;
				height: 160rpx;
				border-radius: 0 0 50% 50%;
				background-color: #4478EF;
			}
		}

		.listTop {
			margin: -130rpx 35rpx 0;
			width: 680rpx;
			height: 330rpx;
			background: #FFFFFF;
			border-radius: 8rpx;
			padding: 30rpx;
			box-sizing: border-box;
			position: relative;

			.label {
				position: absolute;
				top: -11rpx;
				right: 60rpx;

				image {
					position: absolute;
					width: 128rpx;
					height: 69rpx;
					left: 0;
					top: 0;
				}

				text {
					position: relative;
					top: 16rpx;
					left: 10rpx;
					font-size: 24rpx;
					font-weight: 500;
					color: #5A4717;
				}
			}

			.title {
				display: flex;
				align-items: center;

				image {
					width: 50rpx;
					height: 50rpx;
					border-radius: 50%;
					margin-right: 20rpx;
				}

				text {
					font-size: 36rpx;
					font-weight: bold;
					color: #333;
				}
			}

			.count {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				height: 180rpx;

				.a {
					font-size: 72rpx;
					font-weight: bold;
					color: #356BF0;
					line-height: 36rpx;
					margin-bottom: 30rpx;
				}

				.b {
					font-size: 24rpx;
					font-weight: 500;
					color: #666666;
					line-height: 36rpx;
				}
			}

			.desc {
				display: flex;
				justify-content: space-between;

				.a {
					display: flex;
					align-items: center;

					.a-a {
						font-size: 24rpx;
						font-weight: 500;
						color: #666666;
					}

					.a-b {
						margin-left: 6rpx;
						font-size: 30rpx;
						font-weight: bold;
						color: #343434;
					}
				}
			}
		}

		.List {
			padding: 50rpx 35rpx 35rpx;

			.title {
				font-size: 30rpx;
				font-weight: bold;
				color: #343434;
			}

			.item {
				margin-top: 30rpx;
				width: 680rpx;
				height: 240rpx;
				background: #FFFFFF;
				border-radius: 8rpx;
				padding: 20rpx 30rpx;
				box-sizing: border-box;

				.title {
					display: flex;
					align-items: center;
					position: relative;

					image {
						width: 50rpx;
						height: 50rpx;
						border-radius: 50%;
						margin-right: 20rpx;
					}

					text {
						font-size: 32rpx;
						color: #333;
					}

					.goOut {
						position: absolute;
						right: 0;
						width: 40rpx;
						height: 40rpx;
						border-radius: 50%;
						background: #EBF0FB;
						display: flex;
						justify-content: center;
						flex-direction: column;
						align-items: center;

						text {
							margin-left: 4rpx;
							font-size: 20rpx;
							color: #366CF0;
						}
					}
				}

				.box {
					display: flex;
					align-items: center;

					.count {
						display: flex;
						flex-direction: column;
						align-items: center;
						justify-content: center;
						height: 160rpx;
						width: 265rpx;
						min-width: 265rpx;

						.a {
							font-size: 50rpx;
							font-weight: bold;
							color: #356BF0;
							line-height: 36rpx;
							margin-bottom: 20rpx;
						}

						.b {
							font-size: 24rpx;
							font-weight: 500;
							color: #666666;
							line-height: 36rpx;
						}
					}

					.desc {
						flex: 1;
						display: flex;
						justify-content: center;
						flex-direction: column;
						align-items: center;
						padding-top: 20rpx;

						.a {
							display: flex;
							align-items: center;
							margin-bottom: 20rpx;

							.a-a {
								font-size: 24rpx;
								font-weight: 500;
								color: #666666;
							}

							.a-b {
								margin-left: 6rpx;
								font-size: 30rpx;
								font-weight: bold;
								color: #343434;
							}
						}
					}
				}
			}
		}
	}
</style>
